﻿var Code;
var FamilyName;
var Tel;
var ChildName;
var ChildSex;
var ChildAge;
var Address;
jQuery.noConflict();
/**********************发送验证码*******************************/
function SendMessage() {
    if (!isMobile(jQuery("#addphone").val())) { Alert("手机号码输入错误"); return; }
    var stryzmbtn = jQuery(".send").text();
    if (stryzmbtn != "发送验证码") return;
    var user = {
        Mobile: jQuery("#addphone").val(),
    };
    timer(intDiff);
    jQuery.ajax({
        url: 'Handler/DataHandler.ashx?action=yzm',
        data: user,
        type: 'post',
        dataType: 'text',
        success: function (msg) {
            Code = msg;
        },
        error: function (msg) {
            Alert("发送失败");
        }
    })
}
/**********************验证码发送倒计时*******************************/
var intDiff = parseInt(60);
function timer(intDiff) {
    var t = window.setInterval(function () {
        if (intDiff == 0) { jQuery(".send").text("发送验证码"); clearInterval(t); }
        else jQuery(".send").text("重新发送(" + intDiff + ")");
        intDiff--;
    }, 1000);
}

/********************信息提交**************************/
function AddUserInfo() {
    if (jQuery("#addphone").val() == "") {
        Alert("手机号码不能为空");
        return;
    }
    if (Code != jQuery("#yzm").val()) {
        Alert("验证码输入错误");
        return;
    }
    if (jQuery("#familyName").val() == "") {
        Alert("家长姓名不能为空");
        return;
    }


    var user = {
        FamilyName: jQuery("#familyName").val(),
        Tel: jQuery("#addphone").val(),
        ChildName: jQuery("#childName").val(),
        ChildSex: lif,
        ChildAge: jQuery("#ChildAge").val(),
        Address: loc,
    };
    //Alert("正在验证...");
    jQuery.ajax({
        url: 'Handler/DataHandler.ashx?action=save',
        data: user,
        type: 'post',
        dataType: 'text',
        success: function (msg) {

            if (msg == '1') {
                jQuery(".meng").hide();
                jQuery(".enlist").hide();
                jQuery(".meng1").show();
                jQuery(".enlist1").show();
                jQuery("#s1").text(jQuery("#familyName").val());
                jQuery("#s2").text(jQuery("#addphone").val());
                jQuery("#s3").text(jQuery("#childName").val());
                jQuery("#s4").text(lif);
                jQuery("#s5").text(jQuery("#ChildAge").val());
                jQuery("#s6").text(loc);
            }
            else {

            }
        }
    })
}